/**
* @Title: warning_ctrl.js
* @Description: TODO
* Copyright: Copyright (c) 2014 
 * Company:中国平安
*
* @Project HIMS-FWA
* @date 2014年10月27日 下午4:43:38
* @version V1.0
*/
;
(function(){
	'use strict';
	
	var app = angular.module('fwa.mainApp');
	app.controller('CaseAuditDispathDetailResultCtrl', ['$scope','CommunityService','CaseCommonService','$http','$modal','CaseAuditDispathDetailResultService','$state','BaseURL','Modal','FwaTabsetService','$stateParams',
	                                function($scope,CommunityService,CaseCommonService,$http,$modal,CaseAuditDispathDetailResultService,$state,baseUrl,Modal,FwaTabsetService,$stateParams){
		 $scope.requestParam = {
	                page:"1",
	                pageSize:"20"
	            };
        $scope.communityService = CommunityService;
        CommunityService.initCodeListDatas();
        $scope.UrlParams = $stateParams;
		$scope.CaseAuditDispathDetailResultService = CaseAuditDispathDetailResultService;

		$scope.problemtab=[ {label:'事件处理',id:0,url:'views/hcpms/audit/caseAduitDispathDealProblem.html'},
            {label:'调查结果',id:1,url:'views/hcpms/audit/caseAduitDispathDetailsurResult_view.html'}];

        $scope.selectedTable = $scope.problemtab[0];
        $scope.tabIndex = 0;
        $scope.tabClicks = function(tab) {
            $scope.selectedTabs = tab;
            $scope.tabIndex=tab.id;

            if($scope.tabIndex==0){
                initdealPorblemData();
            }
            if($scope.tabIndex==1){
                initProblem();
            }
        }
		
		
		
		//初始化请求参数
        var params = function (){
            var problemNo = "";
            if($stateParams.problemNo && !angular.isUndefined($stateParams.problemNo) ){
                problemNo = $stateParams.problemNo;
            }
            var params = {
                problemNo:problemNo,
                page:$scope.requestParam.page,
                pageSize:$scope.requestParam.pageSize
            }
            return params;
        }
        /**
         * 初始化医疗机构数据
         */
        function initdealPorblemData(){
            var parameter=params();
            CaseAuditDispathDetailResultService.loadDealProblemData(parameter).success(function(response){
                 $scope.treatmentOpinion=response.result.treatmentOpinion;
                 $scope.auditOpinion=response.result.auditOpinion;
            });
        }
        function  initProblem(){
            var parameter=params();
            CaseAuditDispathDetailResultService.loadDealProblem(parameter).success(function(response){
                $scope.treatmentOpinions=response.result.problem;
            });
        }
        /**
         * 初始化医疗机构数据和医护人员信息和参保人信息
         */
        function initMedicalData(){
            var parameter=params();
            CaseCommonService.loadMedicalInfoList(parameter).success(function(response){

                $scope.medicalData2=response.medicalBean.medicalList;
                $scope.staffData2=response.staffBean.staffList;
                $scope.insuranceData2=response.insuranceBean.insuranceList;

            });
        }

        /**
         * 初始化事件数据对象
         */
        function initProblemData(){
            var parameter=params();
            CaseCommonService.loadProblemData(parameter).success(function(response){
                var obj=response.problemObj;
                $scope.object=obj;
            });
        }
        
        /**
         * 点击医疗机构量事件
         * 
         */
        $scope.$on('fwaInvolve.medicalCountClick',function(){
     	   CaseCommonService.viewMedicalDetail($scope);
        });
        
        /**
         * 点击医务人员总数量事件
         */
        $scope.$on('fwaInvolve.staffCountClick',function(){
        	$scope.caseNo = $stateParams.problemNo;
        	CaseCommonService.viewStaffList($scope);
        });
        
        /**
         * 点击参保人总数量事件
         */
        $scope.$on('fwaInvolve.insuranceCountClick',function(){
        	CaseCommonService.viewInsurList($scope);
        });

        /**
         * 返回
         */
        $scope.goBack = function () {
            $state.go("problemResearch");
        };
        initProblemData();
        initMedicalData();
        $scope.tabClicks($scope.problemtab[1]);

                                    }]);
})();
